<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Modal Window</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <!-- Latest compiled and minified CSS -->
    <!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">-->
    <link rel="stylesheet" href="../bootstrap-3.3.7-dist/css/bootstrap.css">
    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
    <!-- Latest compiled and minified JavaScript -->
    <script src="../libs/jquery-3.3.1.js"></script>
    <script src="../bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <style type="text/css">

    </style>
    <script type="text/javascript">
        function test() {
            $('#myModal').modal().show();
        }

        $(function () {
            // $('#myModal').modal({
            //     show : true,
            //     backdrop : true,
            //     keyboard : true
            // });

            $('#myModal').on('show.bs.modal', function () {
                alert('在 show 方法调用时立即触发！');
            });

            $('#myModal').on('shown.bs.modal', function () {
                alert('在模态框显示完毕后触发！');
            });

            $('#myModal').on('hide.bs.modal', function () {
                alert('在 hide 方法调用时立即触发！');
            });


        });
    </script>
</head>
<body>
<div class="container">
    <button class="btn btn-primary" data-toggle="modal" data-target="#myModal">弹出模态框</button>
    <button class="btn btn-success" onclick="test()">测试模态框</button>

    <div class="modal fade" id="myModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"> &times;</button>
                    <h4 class="modal-title"> 标题 </h4></div>
                <div class="modal-body"> 在这里添加一些文本</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary"> 提交</button>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>